package com.ruoyi.common.demo;


import com.github.s7connector.api.S7Connector;

/**
 *
 **/
public class RecycleReadDemo {
    public static void main(String[] args) throws InterruptedException {

        ReadPLCDemo readPLC = new ReadPLCDemo();//创建读取plc数据对象
        while (true) {
            S7Connector connector = initConnect();//初始化
            readPLC.Cyclic_read(connector);//读取
            System.out.println("=============读取plc信息==============");
            System.out.println(readPLC.in_bool1);
            System.out.println(readPLC.in_int);
            System.out.println(readPLC.in_bool2);
            System.out.println(readPLC.in_word);
            System.out.println(readPLC.in_int);
            System.out.println(readPLC.in_String);
            System.out.println(readPLC.in_real);
            System.out.println("=============读取plc信息==============");
            Thread.sleep(1000);//stop 0.5s
        }
    }

    public static S7Connector initConnect() {
        S7ConnectorDemo s7ConnectorPLC = new S7ConnectorDemo();
        S7Connector connector = s7ConnectorPLC.initConnect("192.168.20.100");//plc地址
        return connector;
    }
}